home *** CD-ROM | disk | FTP | other *** search
/ Programming in Microsoft Windows with C# / Programacion en Microsoft Windows con C#.iso / Codigo / Beziers y otros splines / ClosedCurveFillModes / ClosedCurveFillModes.cs next >
Encoding:
Text File  |  2002-05-08  |  1.3 KB  |  40 lines

  1. //---------------------------------------------------
  2. // ClosedCurveFillModes.cs ⌐ 2001 by Charles Petzold
  3. //---------------------------------------------------
  4. using System;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Windows.Forms;
  8.  
  9. class ClosedCurveFillModes: PrintableForm
  10. {
  11.      public new static void Main()
  12.      {
  13.           Application.Run(new ClosedCurveFillModes());
  14.      }
  15.      ClosedCurveFillModes()
  16.      {
  17.           Text = "Modos de llenado de FillClosedCurve";
  18.           ClientSize = new Size(2 * ClientSize.Height, ClientSize.Height);
  19.      }
  20.      protected override void DoPage(Graphics grfx, Color clr, int cx, int cy)
  21.      {
  22.           Brush   brush = new SolidBrush(clr);
  23.           Point[] apt   = new Point[5];
  24.           
  25.           for (int i = 0; i < apt.Length; i++)
  26.           {
  27.                double dAngle = (i * 0.8 - 0.5) * Math.PI;
  28.                apt[i] = new Point(
  29.                               (int)(cx *(0.25 + 0.24 * Math.Cos(dAngle))),
  30.                               (int)(cy *(0.50 + 0.48 * Math.Sin(dAngle))));
  31.           }
  32.           grfx.FillClosedCurve(brush, apt, FillMode.Alternate);
  33.  
  34.           for (int i = 0; i < apt.Length; i++) 
  35.                apt[i].X += cx / 2;         
  36.  
  37.           grfx.FillClosedCurve(brush, apt, FillMode.Winding);
  38.      }
  39. }
  40.